#ifndef SRC_LOGGER_H_

#define SRC_LOGGER_H_

#include <stdio.h>
#include <stdarg.h>
#include <time.h>
#include <iostream>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
#include <string.h>
#include <sys/stat.h> 
#include "File.h"

template <typename E> class logtemplate { public : void test() { throw; } };


#define LOGAUTODATE   0x0001

class  Logger
{
public:

      Logger (const char* zLogSubdir, const char* zLogPrefix, int iFlags = LOGAUTODATE);
      virtual ~Logger();

      void nothingtodo();
      int LogPrintf (const char* zFmt, ... );
      int vLogPrintf (const char *zFmt, va_list args);
      int GetNewDateTime (struct tm* pLastTime, char* szDate, char *szDateTime);
protected:
      int _iPID;
      int _iFlags;
      struct tm _sLastTime;
      std::string _zLogPrefix;
      std::string _zLogBase;
      std::string _zLogDir;
      std::string _zLogFileName;
      File* _pLogFile;
  public:
      Logger();
      int GetIPID ();
      void SetIPID (int value);

      bool EnsureProperLogFileOpen ();

      void Change(const char* str);



      int GetIFlags ();
      void SetIFlags (int value);

      struct tm GetSLastTime ();
      void SetSLastTime (struct tm value);

      std::string GetZLogPrefix ();
      void SetZLogPrefix (std::string value);

      std::string GetZLogBase ();
      void SetZLogBase (std::string value);

      std::string GetZLogDir ();
      void SetZLogDir (std::string value);

      std::string GetZLogFileName ();
      void SetZLogFileName (std::string value);


      File*  GetPLogFile ();

      void SetPLogFile (File* str);
  private:

};

class platform
{
public:
	static std::string native_path(std::string);
};




inline int Logger::GetIPID ()
{
  return _iPID;
}

inline void Logger::SetIPID (int value)
{
  _iPID = value;
}

inline int Logger::GetIFlags ()
{
  return _iFlags;
}

inline void Logger::SetIFlags (int value)
{
  _iFlags = value;
}

inline struct tm Logger::GetSLastTime ()
{
  return _sLastTime;
}

inline void Logger::SetSLastTime (struct tm value)
{
  _sLastTime = value;
}

inline std::string Logger::GetZLogPrefix ()
{


	return _zLogPrefix;
}

inline void Logger::SetZLogPrefix (std::string value)
{
  _zLogPrefix = value;
}

inline std::string Logger::GetZLogBase ()
{
  return _zLogBase;
}

inline void Logger::SetZLogBase (std::string value)
{
  _zLogBase = value;
}

inline std::string Logger::GetZLogDir ()
{
  return _zLogDir;
}

inline void Logger::SetZLogDir (std::string value)
{
  _zLogDir = value;
}

inline std::string Logger::GetZLogFileName ()
{
  return _zLogFileName;
}

inline void Logger::SetZLogFileName (std::string value)
{
  _zLogFileName = value;
}

inline File* Logger::GetPLogFile ()
{
  return _pLogFile;
}

inline void Logger::SetPLogFile (File* str)
{
	_pLogFile = str;
}

#endif /* SRC_LOGGER_H_ */
